package com.inno.subject.infra.basic.service.impl;

import com.github.pagehelper.Page;
import com.inno.subject.infra.basic.entity.PlannerSubjectInfo;
import com.inno.subject.infra.basic.mapper.PlannerSubjectInfoDao;
import com.inno.subject.infra.basic.service.PlannerSubjectInfoService;
import com.inno.subject.infra.entity.CategorySubjectCountEntity;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * (PlannerSubjectInfo)表服务实现类
 *
 * @author makejava
 * @since 2024-11-16 20:57:05
 */
@Service
public class PlannerSubjectInfoServiceImpl implements PlannerSubjectInfoService {
    @Resource
    private PlannerSubjectInfoDao plannerSubjectInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerSubjectInfo queryById(Long id) {
        return this.plannerSubjectInfoDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param plannerSubjectInfo 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectInfo insert(PlannerSubjectInfo plannerSubjectInfo) {
        this.plannerSubjectInfoDao.insert(plannerSubjectInfo);
        return plannerSubjectInfo;
    }

    /**
     * 修改数据
     *
     * @param plannerSubjectInfo 实例对象
     * @return 实例对象
     */
    @Override
    public int update(PlannerSubjectInfo plannerSubjectInfo) {

        return this.plannerSubjectInfoDao.update(plannerSubjectInfo);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerSubjectInfoDao.deleteById(id) > 0;
    }

    @Override
    public Page<PlannerSubjectInfo> queryPage(PlannerSubjectInfo entity,int page,int pageSize) {
        return this.plannerSubjectInfoDao.queryPage(entity, page, pageSize);
    }

    @Override
    public Long queryCursor(Long categoryId, String subjectLevel, Long subjectType, int cursor, Date createTime) {
        return this.plannerSubjectInfoDao.queryCursor(categoryId,subjectLevel,subjectType,cursor,createTime);
    }

    @Override
    public List<PlannerSubjectInfo> queryByIdList(List<Long> subjectIdList) {
        return this.plannerSubjectInfoDao.queryByIdList(subjectIdList);
    }

    @Override
    public void batchDeleteByIdList(List<Long> ids) {
        this.plannerSubjectInfoDao.batchDelete(ids);

    }

    @Override
    public void batchInsert(List<PlannerSubjectInfo> list) {
        this.plannerSubjectInfoDao.insertBatch(list);
    }

    @Override
    public Long queryPageCount(PlannerSubjectInfo entity) {
        return this.plannerSubjectInfoDao.count(entity);
    }

    @Override
    public List<CategorySubjectCountEntity> queryCategorySubjectCount() {
        return this.plannerSubjectInfoDao.queryCategorySubjectCount();
    }
}
